package com.java.zhuiyun.api.idiomAdventureManager.controller;

import com.java.zhuiyun.annotation.OptLog;
import com.java.zhuiyun.api.idiomAdventureManager.entity.IdiomAdventureQuestionBank;
import com.java.zhuiyun.api.idiomAdventureManager.model.IdiomAdventureQuestionBankModel;
import com.java.zhuiyun.api.idiomAdventureManager.service.IdiomAdventureQuestionBankService;
import com.java.zhuiyun.common.errorCode.CommonException;
import com.java.zhuiyun.common.response.CommonConstants;
import com.java.zhuiyun.common.response.CommonResult;
import com.java.zhuiyun.util.pageUtil.PageRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName IdiomAdventureQuestionBankController
 * @Description TODO 冒险题库管理
 * @Author WX
 * @Date 2023/9/13 9:17
 **/
@Api(tags = "冒险题库管理")
@RestController
@CrossOrigin
@RequestMapping("/IdiomAdventureQuestionBank")
@Slf4j
public class IdiomAdventureQuestionBankController {
    @Autowired
    private IdiomAdventureQuestionBankService idiomAdventureQuestionBankService;

    /*
     * @Author WX
     * @Description 查询所有数据或根据输入字段查询
     * @Date 2023/9/13 10:26
     * @Return
     * @param IdiomAdventureQuestionBank PageRequest
     */
    @RequestMapping ("/selectIdiomAdventureQuestionBankAllByOne")
    @ApiOperation(value = "查询所有数据或根据输入字段查询")
    @OptLog(modular = "冒险词库管理",type = CommonConstants.SELECT,describe = "查询所有数据或根据输入字段查询")
    public CommonResult selectIdiomAdventureQuestionBankAll (IdiomAdventureQuestionBank idiomAdventureQuestionBank, PageRequest pageRequest) {
        return idiomAdventureQuestionBankService.selectIdiomAdventureQuestionBankAllByOne(idiomAdventureQuestionBank,pageRequest);
    }

    /*
     * @Author WX
     * @Description 添加词库
     * @Date 2023/9/13 11:18
     * @Return
     * @param idiomAdventureQuestionBank
     */
    @PostMapping("/addIdiomAdventureQuestionBank")
    @ApiOperation(value = "添加词库")
    @OptLog(modular = "冒险词库管理",type = CommonConstants.ADD,describe = "添加词库")
    public CommonResult addIdiomAdventureQuestionBank(@RequestBody IdiomAdventureQuestionBankModel idiomAdventureQuestionBankModel)   throws CommonException {
        return CommonResult.ok(idiomAdventureQuestionBankService.addIdiomAdventureQuestionBank(idiomAdventureQuestionBankModel));
    }

    /*
     * @Author WX
     * @Description 查询单个
     * @Date 2023/9/13 14:01
     * @Return
     * @param id
     */
    @GetMapping("/findIdiomAdventureQuestionBankById")
    @ApiOperation(value = "查询单个")
    @OptLog(modular = "冒险词库管理",type = CommonConstants.SELECT,describe = "查询单个")
    public CommonResult findIdiomAdventureQuestionBankById (Integer id) throws CommonException {
        return CommonResult.ok(idiomAdventureQuestionBankService.findIdiomAdventureQuestionBankById(id));
    }

    /*
     * @Author WX
     * @Description 修改单个
     * @Date 2023/9/13 14:07
     * @Return
     * @param idiomAdventureQuestionBank
     */
    @PostMapping("/updateIdiomAdventureQuestionBankById")
    @ApiOperation(value = "修改单个")
    @OptLog(modular = "冒险词库管理",type = CommonConstants.UPDATE,describe = "修改单个")
    public CommonResult updateIdiomAdventureQuestionBankById (@RequestBody IdiomAdventureQuestionBankModel idiomAdventureQuestionBankModel) throws CommonException{
        return CommonResult.ok(idiomAdventureQuestionBankService.updateIdiomAdventureQuestionBankById(idiomAdventureQuestionBankModel));
    }


    /*
     * @Author WX
     * @Description 删除
     * @Date 2023/9/13 14:17
     * @Return
     * @param id
     */
    @GetMapping("/deleteIdiomAdventureQuestionBankById")
    @ApiOperation(value = "删除")
    @OptLog(modular = "冒险词库管理",type = CommonConstants.DELETE,describe = "删除")
    public CommonResult deleteIdiomAdventureQuestionBankById (Integer id) throws CommonException {
        return CommonResult.ok(idiomAdventureQuestionBankService.deleteIdiomAdventureQuestionBankById(id));
    }

    /*
     * @Author WX
     * @Description 数据库随机查10条
     * @Date 2023/9/14 13:56
     * @Return
     * @param null
     */
    @GetMapping("/selectIdiomAdventureQuestionBankRadomByTen")
    @ApiOperation(value = "数据库随机查10条")
    @OptLog(modular = "冒险词库管理",type = CommonConstants.SELECT,describe = "数据库随机查10条")
    public CommonResult selectIdiomAdventureQuestionBankRadomByTen () {
        return CommonResult.ok(idiomAdventureQuestionBankService.selectIdiomAdventureQuestionBankRadomByTen());
    }
}



